package thread;
/**
 获取一个线程相关信息的方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread t=new Thread(){
            public void run(){
                //定义的线程若没有指定名字，系统会分配一个名字
                //默认为Thread-xx
                String name=this.getName();
                System.out.println(name);//Thread-0
                long id=this.getId();//id
                System.out.println(id);
                int priority=this.getPriority();//优先级
                System.out.println(priority);
                boolean isInterrupted =this.isInterrupted();
                boolean isDaemon=this.isDaemon();
                boolean isAlive=this.isAlive();
                System.out.println("是否被中断:"+isInterrupted);
                System.out.println("是否是守护线程:"+isDaemon);
                System.out.println("是否还活着:"+isAlive);


            }
        };
        t.start();
    }
}
